<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>v-bind动态绑定（数组语法）</title>
</head>
<style>
  .active {
    color: aqua;
  }

  .line {
    background-color: darkmagenta;
  }

  .title {
    font-family: 华文楷体;
  }
</style>
<body>
<!--v-bind:class的值也可以是数组，同样可以兼容普通的class-->
<div id="app">
  <h2 class='title' :class="['active','line']">{{message}}</h2>
  <hr>
  <h2 class='title' :class="[finalActive,finalLine]">{{message}}</h2>
  <h2 class='title' :class="getClass()">{{message}},简洁的写法</h2>
  <button v-on:click="isClass">渲染</button>
  <button v-on:click="isNotClass">取消渲染</button>
</div>
<script src="../js/vue.js"></script>
<script>
  const app = new Vue({
    el: '#app',
    data: {
      message: 'Hello Vue',
      finalActive: '',
      finalLine: ''
    },
    methods: {
      // 使得页面简洁的写法
      getClass() {
        return [this.finalActive, this.finalLine];
      },
      isNotClass() {
        this.finalActive = '';
        this.finalLine = '';
      },
      isClass() {
        this.finalActive = 'active';
        this.finalLine = 'line';
      }
    }
  });
</script>
</body>
</html>
